//
//  ZYCNewsBulletinCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/29.
//

#import "ZYCNewsBulletinCell.h"
#import "ZYCNewBulletinModel.h"

@interface ZYCNewsBulletinCell ()

@property (nonatomic, strong) UIView *bgWhiteView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *line;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *nameLabel;

@end

@implementation ZYCNewsBulletinCell

- (void)setModel:(ZYCNewBulletinModel *)model{
    _model = model;
    _titleLabel.text = model.title;
    _timeLabel.text = model.createTime;
    _nameLabel.text = model.publisher;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.bgWhiteView];
        [self.bgWhiteView addSubview:self.titleLabel];
        [self.bgWhiteView addSubview:self.line];
        [self.bgWhiteView addSubview:self.timeLabel];
        [self.bgWhiteView addSubview:self.nameLabel];

        [self.bgWhiteView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(9.5f);
            make.right.equalTo(self.contentView).offset(-9.5f);
            make.top.bottom.equalTo(self.contentView);
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgWhiteView).offset(9.5f);
            make.right.equalTo(self.bgWhiteView).offset(-9.5f);
            make.top.equalTo(self.bgWhiteView).offset(10.0f);
        }];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgWhiteView).offset(9.5f);
            make.right.equalTo(self.bgWhiteView).offset(-9.5f);
            make.top.equalTo(self.titleLabel.mas_bottom).offset(17.0f);
            make.height.mas_equalTo(1.0f);
        }];
        
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgWhiteView).offset(9.5f);
            make.top.equalTo(self.line.mas_bottom).offset(19.0f);
            make.bottom.equalTo(self.bgWhiteView).offset(-10.5f);
        }];
        
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.bgWhiteView).offset(-9.5f);
            make.centerY.equalTo(self.timeLabel);
        }];
        
    }
    return self;
}


- (UIView *)bgWhiteView {
    if (!_bgWhiteView) {
        _bgWhiteView = [[UIView alloc] init];
        _bgWhiteView.backgroundColor = HEX_RGB(@"#FFFFFF");
        _bgWhiteView.layer.cornerRadius = 7.5;
        _bgWhiteView.layer.masksToBounds = YES;
    }
    return _bgWhiteView;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kSystemBoldFont(17) titleColor:HEX_RGB(kTitleThemeColor) textAlignment:ZZTextAlignmentLeft];
        _titleLabel.numberOfLines = 0;
    }
    return _titleLabel;
}

- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _timeLabel;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
    }
    return _nameLabel;
}


- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = HEX_RGB(@"#EAEAEA");
    }
    return _line;
}

@end
